package tray

import (
	// 静态导入
	_ "embed"

	"gitee.com/xuender/oils/logs"
	"github.com/getlantern/systray"
)

//go:embed icon.png
var icon []byte

// Service 托盘服务.
type Service struct {
}

// Run 运行.
func (p *Service) Run() {
	systray.Run(p.ready, p.exit)
}

func (p *Service) ready() {
	logs.Debug("ready")
	systray.SetIcon(icon)
	systray.SetTitle("纸飞机")
	systray.SetTooltip("局网沟通软件")

	mQuitOrig := systray.AddMenuItem("退出", "退出纸飞机")

	go func() {
		<-mQuitOrig.ClickedCh
		logs.Debug("Requesting quit")
		systray.Quit()
		logs.Debug("Finished quitting")
	}()
}

func (p *Service) exit() {
	logs.Debug("exit")
}
